



(function(Global /*, context */) {
    Global.Config={
        abilityAttrColor:"#61ff91",
        abilityAttrBgColor:"gradient( linear, 0% 0%, 100% 0%, from( rgb(162, 221, 123) ), to( rgb(123, 168, 93) ))",
        abilityBasicColor:"#3e79fc",
        abilityBasicBgColor:"gradient( linear, 0% 0%, 100% 0%, from(rgb(86, 128, 191)), to(rgb(70, 105, 158)))",
        abilityUltColor:"#fabf1b",
        abilityUltBgColor:"gradient( linear, 0% 0%, 100% 0%, from(rgb(216, 161, 57)), to(rgb(192, 143, 51)))",
    };
    var dotaHud = $.GetContextPanel().GetParent().GetParent()
    Global.GameConfig = CustomNetTables.GetTableValue("game_config", "all");
    Global.Panel={
        dotaHud : dotaHud
    };


    var teamColors = CustomNetTables.GetTableValue("game_config", "team_color");
    $.Msg(teamColors)
    GameUI.CustomUIConfig().team_colors = {}
    for(var index in teamColors){
        GameUI.CustomUIConfig().team_colors[index]=teamColors[index]
    }

    GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_KILLCAM, false );
    GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_QUICK_STATS, false );
    GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_TOP_BAR_RADIANT_TEAM, false );
    GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_TOP_BAR_BACKGROUND, false );
    GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_TOP_BAR, false );
    GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_PANEL, false );
    GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_GOLD, false );
    GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_COURIER, false );
    GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_PROTECT, false );
    GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_ITEMS, false );
GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_PREGAME_STRATEGYUI, false );
GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_TOP_TIMEOFDAY, false );
GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_TOP_HEROES, false );
GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_FLYOUT_SCOREBOARD, false );
GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_GOLD, false );
GameUI.SetDefaultUIEnabled(DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_SHOP, false);
GameUI.SetDefaultUIEnabled(DotaDefaultUIElement_t.DOTA_DEFAULT_UI_SHOP_SUGGESTEDITEMS, false);
GameUI.SetDefaultUIEnabled(DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_QUICKBUY, false);
GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_ENDGAME, false );


var NoGlyphAndRadar = $.GetContextPanel().GetParent().GetParent().FindChildTraverse("HUDElements").FindChildTraverse("minimap_container");
    NoGlyphAndRadar.FindChildTraverse("GlyphScanContainer").style.visibility = "collapse";
    dotaHud.FindChildTraverse("inventory_tpscroll_container").style.visibility = "collapse";
    dotaHud.FindChildrenWithClassTraverse("TertiaryAbilityContainer")[0].style.visibility = "collapse";
//隐藏天赋树
var center_block = dotaHud.FindChildTraverse("HUDElements").FindChildTraverse("center_block");
center_block.FindChildTraverse("StatBranch").style.visibility = "collapse";
//you are not spawning the talent UI, fuck off (Disabling mouseover and onactivate)
center_block.FindChildTraverse("StatBranch").SetPanelEvent("onmouseover", function(){});
center_block.FindChildTraverse("StatBranch").SetPanelEvent("onactivate", function(){});

    dotaHud.FindChildTraverse("PreGame").visible=false;

    center_block.FindChildTraverse("left_flare").style.backgroundImage="url(\"file://{resources}/images/custom_game/left_flare.png\")";
    center_block.FindChildTraverse("left_flare").style.backgroundSize="100%";


// function TogglePanel() {
//     GameEvents.SendEventClientSide("toggle_abilities_shop",{})
// }

// function TogglePlayerInfo(command){
//     $.Msg("TogglePlayerInfo ",command)
//     GameEvents.SendEventClientSide("toggle_player_info",{isOpen:command==="+TAB"})
// }

function CastAbilityByHotKey(index){
   var heroIndex= Players.GetPlayerHeroEntityIndex( Game.GetLocalPlayerID())
    Abilities.ExecuteAbility( Entities.GetAbility( heroIndex, Number(index)), heroIndex, false )
}

// Game.AddCommand( "TogglePanel", TogglePanel, "", 0 );
//     Game.CreateCustomKeyBind("ALT", "-Alt");
//     Game.CreateCustomKeyBind("ALT", "+Alt");
// Game.AddCommand( "+Tab", TogglePlayerInfo, "", 0 );
// Game.AddCommand( "Alt", TogglePlayerInfo, "", 0 );

Game.CreateCustomKeyBind("Z", "12");
Game.CreateCustomKeyBind("X", "13");
Game.CreateCustomKeyBind("C", "14");
Game.CreateCustomKeyBind("V", "15");
Game.CreateCustomKeyBind("B", "16");
Game.CreateCustomKeyBind("N", "17");
Game.AddCommand("12", CastAbilityByHotKey, "", 0);
Game.AddCommand("13", CastAbilityByHotKey, "", 0);
Game.AddCommand("14", CastAbilityByHotKey, "", 0);
Game.AddCommand("15", CastAbilityByHotKey, "", 0);
Game.AddCommand("16", CastAbilityByHotKey, "", 0);
Game.AddCommand("17", CastAbilityByHotKey, "", 0);

    function OnPlayerInfoChange(table, key, data) {
        // $.Msg("player_info",data)
        for(var i in data){
            if(Number(data[i].playerId)===Players.GetLocalPlayer()){
                Global.Panel.topBar&&Global.Panel.topBar.SetData(data[i]);
                break
            }
        }
        Global.Panel.playerInfo&&Global.Panel.playerInfo.SetData(data)
    }

    CustomNetTables.SubscribeNetTableListener("player_info", OnPlayerInfoChange);

})(GameUI.CustomUIConfig(), this);


